<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>02绝对定位</title>
    <style>
        div{
            width: 100px;
            height: 100px;
            border: 2px solid red;
        }
        #d1{
            /*绝对定位:元素脱离文档流,后面元素会顶上来*/
            position: absolute;
            /*相对于窗口做位置偏移*/
            right: 10px;
            bottom: 10px;
        }
        #big{
            width: 200px;
            height: 200px;
            background-color: #5cb85c;
            margin: 100px 0 0 100px;
        }
        #big>div{
            width: 100px;
            height: 100px;
            background-color: pink;
            /*通过给元素添加边框,也能解决粘连问题,
            但是会影响上级元素的显示效果,所以不推荐*/
            margin: 50px 0 0 50px;
            position: relative;/*做参照物*/
        }
        #big>div>div{
            width: 50px;
            height: 50px;
            background-color: #5bc0de;
            /*绝对定位默认相对于窗口
            想让它相对谁(上级元素)就在谁里面添加 position: relative*/
            position: absolute;
            left:0;
            top: 0;
        }
    </style>
</head>
<body>
    <div id="big">
        <div>
            <div></div>
        </div>
    </div>

    <div id="d1">div1</div>
    <div>div2</div>
</body>
</html>